SPB Git

spb/autoscholar

Public
1019 B · 30 lines typescript
1import { getPaperBySlug, risFor } from "@autoscholar/core";2import { handler } from "@/lib/server/api";3import { db } from "@/lib/server/db";45export const runtime = "nodejs";67export const GET = handler(async (_req, { params }) => {8  const { slug } = (await params) as { slug: string };9  const p = await getPaperBySlug(db(), slug);10  const base = process.env.APP_BASE_URL ?? "http://localhost:8470";11  const pub = new Date(p.version.publishedAt);12  const text = risFor({13    publicId: p.paper.publicId,14    title: p.version.title,15    year: pub.getUTCFullYear(),16    month: pub.getUTCMonth() + 1,17    versionNo: p.version.versionNo,18    url: `${base}/research/${p.paper.slug}`,19    keywords: p.version.keywords,20    abstract: p.version.abstract,21  });22  return new Response(text, {23    headers: {24      "content-type": "application/x-research-info-systems; charset=utf-8",25      "content-disposition": `attachment; filename="${p.paper.publicId}.ris"`,26      "cache-control": "public, max-age=3600",27    },28  });29});30
Files · main
Menu

Theme